﻿using MediatR;
using Rabbit.Domain;
using Rabbit.ErCode;
using Rabbit.lnfarnum;
using Rabbit.Read.API.GetRepository.Commders;

namespace Rabbit.Read.API.GetRepository.CommdHenders
{
    public class BackfillMerchandCommdHnader : IRequestHandler<BackfillMerchandCommder, APIResult<List<MerchandiseMangem>>>
    {
        private readonly IBaseRepository<MerchandiseMangem> baseRepository;

        public BackfillMerchandCommdHnader(IBaseRepository<MerchandiseMangem> baseRepository)
        {
            this.baseRepository = baseRepository;
        }

        public Task<APIResult<List<MerchandiseMangem>>> Handle(BackfillMerchandCommder request, CancellationToken cancellationToken)
        {
            APIResult<List<MerchandiseMangem>> result = new APIResult<List<MerchandiseMangem>>();


            result.Code =ReCode.查询成功;
            result.Mage =ReCode.查询成功.ToString();

            var list = baseRepository.GetAll().Where(x => x.MerchandMangeid == request.MerchandMangeid);

            result.Data =list.ToList();

            return Task.FromResult(result);
        }
    }
}
